import { getTreeSubject } from "@/api/subject";

const state = () => ({
    treeList: [], // 树形学科、目录、标签数据
});

const getters = {
    treeList: (state) => state.treeList,
};

const mutations = {
    // 设置列表数据
    SET_LIST(state, data) {
        state.treeList = data;
    },
};

const actions = {
    // 请求学科列表
    async loadTreeList({ commit }, data) {
        const res = await getTreeSubject(data);
        commit("SET_LIST", res);
    },
};

export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions,
};